package com.fuhailiu.opengl.renders;

import android.content.Context;

import com.fuhailiu.opengl.utils.ArrayUtil;
import com.fuhailiu.opengl.utils.LogUtil;
import com.fuhailiu.opengl.view.GLViewGroup;
import com.fuhailiu.opengl.widget.GLFBO;

public class RenderFBO extends AbsRender {

	private final String TAG = getClass().getSimpleName();

	private GLFBO mGLFBO;

	public RenderFBO(Context context) {
		super(context);
	}

	@Override
	protected GLViewGroup makeWorld(Context context) {
		LogUtil.LogD(TAG, "makeWorld   <---");

		GLViewGroup layout = new GLViewGroup(context);

		mGLFBO = new GLFBO(context, mSurfaceWidth, mSurfaceHeight);
		layout.addView(mGLFBO);

		LogUtil.LogD(TAG, "makeWorld   --->");

		return layout;
	}

	private final String[] menuArray = new String[] { "Off Screen", "On Screen" };
	private final boolean[] menuFunc = new boolean[] { true, false };

	@Override
	public String[] getMenuInfo() {
		return menuArray;
	}

	@Override
	public void onMenuSelected(String title) {
		int index = ArrayUtil.getIndex(menuArray, title);
		if (index != -1) {
			boolean bOffScreen = menuFunc[index];
			mGLFBO.setOffScreen(bOffScreen);
		}
	}

}
